package com.baymax.study.base.aop_impl.advices;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * MyCustomerAdvice
 *
 * @author Baymax
 * @since 2024-09-2024/9/17
 */
@Aspect
@Component
public class MyCustomerAdvice {
    @Pointcut("execution(* com.baymax.study.base.aop_impl.*.*(..))")
    public void pointcut() {
    }

    @Around("pointcut()")
    public Object aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("aroundAdvice 环绕通知-前置通知");
        Object result = joinPoint.proceed();
        System.out.println("aroundAdvice 环绕通知-后置通知");
        return result;
    }

    @Before("pointcut()")
    public void beforeAdvice(JoinPoint joinPoint) {
        System.out.println("beforeAdvice 前置通知执行");
    }
}
